import { createRoot } from "react-dom/client";
import Show from "./show";
import { isClient, isMobile } from "@/app/utils";
import { Modal } from "antd";
export const closeFnSet = new Set<() => void>();
function Confirm(props) {
  let mobile = isClient() && isMobile(navigator.userAgent);
  if (!mobile) {
    Modal.confirm({
      ...props,
      okText: "确认",
      title: "提示",
      cancelText: "取消",
    });
    return;
  }
  const container = document.createElement("div");
  document.body.appendChild(container);
  const root = createRoot(container);
  const close = () => {
    root.unmount();
    document.body.removeChild(container);
  };
  closeFnSet.add(close);
  root.render(<Show {...props} />);
}

export default Confirm;
